import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsUUID, IsInt, Min, Max, IsOptional, IsBoolean } from 'class-validator';

export class CreateCommentDto {
  @ApiProperty({ description: '评论内容', example: '这本书非常精彩，强烈推荐！' })
  @IsNotEmpty({ message: '评论内容不能为空' })
  @IsString({ message: '评论内容必须是字符串' })
  content: string;

  @ApiProperty({ description: '评分（0-5）', example: 5 })
  @IsInt({ message: '评分必须是整数' })
  @Min(0, { message: '评分最小为0' })
  @Max(5, { message: '评分最大为5' })
  rating: number;

  @ApiProperty({ description: '图书ID', example: 'uuid' })
  @IsNotEmpty({ message: '图书ID不能为空' })
  @IsUUID('4', { message: '图书ID格式不正确' })
  book_id: string;

  @ApiProperty({ description: '是否显示', example: true, required: false })
  @IsOptional()
  @IsBoolean({ message: '是否显示必须是布尔值' })
  is_visible?: boolean;
}